function getLanguage(_this) {
  return _this.$store.getters.getLanguage;
}

function categoryLoading(_this) {
  _this
    .$http({
      url: "/api/index/category/movieCategoryData",
      params: {
        language: getLanguage(_this)
      }
    })
    .then(function(res) {
      _this.langCategoryData = res.data.data.addressData;
      _this.typeCategoryData = res.data.data.typeData;
    });
}

function movieLoading(_this, options) {
  _this
    .$http({
      url: "/api/index/movie/index",
      params: options
    })
    .then(function(res) {
      if (res.data.code == 1) {
        _this.movieList = res.data.data.data;
        _this.count = res.data.data.count;
      }
    });
}

function movieDetailLoading(_this) {
  let that = _this;
  _this
    .$http({
      url: "/api/index/movie/detail",
      params: {
        id: _this.id
      }
    })
    .then(function(res) {
      that.data = res.data.data;
    });
}

function testPlaySource(_this) {
  let that = _this;
  _this
    .$http({
      url: "/api/index/movie/testPlaySource",
      params: {
        id: _this.id
      }
    })
    .then(function(res) {
      that.data = res.data.data;
    });
}

function searchLoading(_this) {
  _this
    .$http({
      url: "/api/index/movie/search",
      params: {
        namePY: _this.searchContent
      }
    })
    .then(function(res) {
      if (res.data.code === 1) {
        _this.searchResList = res.data.data;
      }
    });
}

function searchRes(_this) {
  _this
    .$http({
      url: "/api/index/movie/search",
      params: {
        namePY: _this.value,
        language: getLanguage(_this)
      }
    })
    .then(res => {
      if (res.data.code == 1) {
        _this.searchData = res.data.data;
      }
    });
}
export default {
  categoryLoading,
  movieLoading,
  movieDetailLoading,
  searchLoading,
  testPlaySource,
  searchRes
};
